function saveData() {
         //получаем массив координат из кукисов
         var coord = get_cookie('latLng');
         //формируем урл и отправляем его GETом
         var url = "saveroutes/coord/" + coord;     
         downloadUrl(url, function(data, responseCode) {
             if (responseCode == 200 && data.length <= 1) {
                 infowindow.close();
                 document.getElementById("message").innerHTML = "Added.";
             }
         });
       }

function downloadUrl(url, callback) {
    var request = window.ActiveXObject ?
    new ActiveXObject('Microsoft.XMLHTTP') :
    new XMLHttpRequest;
      
    request.onreadystatechange = function() {
        if (request.readyState == 4) {
            request.onreadystatechange = doNothing;
            callback(request.responseText, request.status);
        }
    };
    
    request.open('GET', url, true);
    request.send(null);
}

function doNothing() {}
       
function get_cookie ( cookie_name ) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
 
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function redir(url) {
    lang = window.location.pathname.substr(1, 3);
    window.location.href= '/' + lang + url;;
}

function delete_cookie ( cookie_name ) {
  var cookie_date = new Date ( ); 
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}